/**
 * Created by ziyu on 17/5/8.
 */

import React, {Component, PropTypes} from 'react'
import Styles from './Index.less'
import SearchStyle from '../../common/less/search.less'
import {message, Col, Icon, Button, Form, Input, Spin} from 'antd'
import {fetchPost} from '../../../utils/request'
import Search from '../../common/components/Search'
import DlButton from '../../common/components/download/DlButton'
import List from './List'

import moment from 'moment'

class Index extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      params: {
        startDate: moment().format('YYYY-MM-DD'),
        endDate: moment().format('YYYY-MM-DD'),
      },
      searchParams: {
        list: [
          {
            name: 'Date',
            type: 'range',
            key: ['startDate', 'endDate'],
            className: 'pr20',
            placeHolder: '',
            values: [
              moment(),
              moment(),
            ]
          },
          {
            name: '',
            type: 'search',
            key: '',
            className: 'pr20',
            values: []
          }
        ],
        // api: '/collection/v2/case/query'
      },
    }
  }

  componentDidMount() {
  }

  componentWillReceiveProps(props) {
  }

  changeParams(params) {
    this.setState({
      params,
    })
  }

  render() {
    return (
      <div>
        <div className={SearchStyle.searchClass}>
          <Search searchParams={this.state.searchParams} changeParams={(params) => this.changeParams(params)}/>
        </div>

        <div>
          <DlButton downloadParams={this.state.params} downloadUrl='/collection/v2/paid/list/export'/>
        </div>

        <div>
          <List params={this.state.params}/>
        </div>

      </div>
    )
  }
}

Index = Form.create()(Index)
export default Index
